import { Service } from "cl-admin";
import BaseService from "@/service/base";
@Service("servicecard")
class Servicecard extends BaseService {
	// 客户卡列表
	cardlist(params) {
		return this.$get("/cardlist", { params });
	}
	// 获取卡详情
	cardinfo(params) {
		return this.$get("/cardinfo", { params });
	}
	// 获取卡操作记录
	cardoplist(params) {
		return this.$get("/cardoplist", { params });
	}
	// 获取卡消费记录
	carduse(params) {
		return this.$get("/carduse", { params });
	}

	// 客户卡失效
	cardinvalid(params) {
		return this.$post("/cardinvalid", params);
	}

	// 修改客户卡购买价格
	cardeditprice(params) {
		return this.$post("/cardeditprice", params);
	}

	// 修改卡延期
	carddelay(params) {
		return this.$post("/carddelay", params);
	}
	// 修改卡余额，次数，折扣
	cardeditnum(params) {
		return this.$post("/cardeditnum", params);
	}

	// 服务卡列表
	lists(params) {
		return this.$get("/lists", { params });
	}
	pageLists({ size, category = [], ...args }) {
		let params = {
			...args,
			pagesize: size,
			size
		};
		if (category && category.length) {
			params.f_category = category[0]
			params.s_category = category[1]

		}
		return this.$get("/lists", { params }).then(res => {
			return {
				list: res.data,
				pagination: {
					...params,
					total: res.total
				}
			};
		});
	}

	// 服务卡添加
	add(params) {
		return this.$post("/add", params);
	}

	// 服务卡编辑
	edit(params) {
		return this.$post("/edit", params);
	}
	// 服务卡详情
	info(params) {
		return this.$get("/info", { params });
	}
	// 服务卡删除
	del(params) {
		return this.$post("/del", params);
	}

	// 用户加卡
	buycard(params) {
		return this.$post("/buycard", params);
	}
}
export default Servicecard;
